package st.business.tepth.business.driverinfo;

import st.business.tepth.base.OnDataConvertListener;
import st.business.tepth.business.bean.DriverWorkRecordBean;
import st.business.tepth.business.bean.PagingBean;

/**
 * Author: shadow
 * Email:  1025431817@qq.com
 * Time:   2019-03-01 11:55
 */

public class DriverInfoPresenter extends DriverInfoContract.Presenter {
    private final DriverInfoContract.View mView;
    private final DriverInfoContract.Model mModel;

    public DriverInfoPresenter(DriverInfoContract.View view) {
        mView = view;
        mModel = new DriverInfoModel();
    }

    @Override
    void getWorkRecord(String token, String jobNo, String startDate,
                       String endDate, int pageNumber, int pageSize, final boolean isRefresh) {
        addDisposable(mModel.getWorkRecord(token, jobNo, startDate,
                endDate, pageNumber, pageSize,
                new OnDataConvertListener<PagingBean<DriverWorkRecordBean>>() {
                    @Override
                    public void convert(PagingBean<DriverWorkRecordBean> pagingBean) {
                        if (mView != null) {
                            mView.showData(pagingBean,isRefresh);
                        }
                    }

                    @Override
                    public void error(int code, String msg) {
                        if (mView != null) {
                            mView.showData(null,isRefresh);
                        }
                    }
                }));
    }
}
